package d1113.r211.num16;


    public abstract class Animal {
        protected String name;

        public Animal() {
        }

        public Animal(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
        //抽象方法，只规定子类该有的功能，不能写具体内容
        protected abstract void shout();
        protected  void eat(Food food){
            System.out.print(this.name+"正在吃着"+food.getName());
        }
    }

    class Cat extends Animal {

    public Cat(String name) {
        super(name);
    }
    @Override
    public void shout(){
        System.out.println(",喵喵喵~~~");
    }

}

    class Dog extends Animal {
    public Dog(String name) {
        super(name);
    }
    @Override
    public void shout(){
        System.out.println(",汪汪汪~~~");
    }
}

